﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace SCZS.Example.Model.Example
{
    public partial class ExampleContext : DbContext
    {
        public ExampleContext()
        {
        }

        public ExampleContext(DbContextOptions<ExampleContext> options)
            : base(options)
        {
        }

        public virtual DbSet<SysUserInfo> SysUserInfos { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql("server=39.103.180.125;uid=root;pwd=example@123;database=Example", Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.36-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8_general_ci")
                .HasCharSet("utf8");

            modelBuilder.Entity<SysUserInfo>(entity =>
            {
                entity.ToTable("SYS_UserInfo");

                entity.HasComment("用户信息表");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasComment("主键");

                entity.Property(e => e.Age)
                    .HasColumnType("int(11)")
                    .HasComment("年龄");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP")
                    .HasComment("创建时间");

                entity.Property(e => e.IsDeleted)
                    .HasColumnType("int(11)")
                    .HasComment("是否删除 1-删除");

                entity.Property(e => e.Password)
                    .HasMaxLength(200)
                    .HasComment("用户密码");

                entity.Property(e => e.Phone)
                    .HasMaxLength(50)
                    .HasComment("手机号");

                entity.Property(e => e.Salt)
                    .HasMaxLength(500)
                    .HasComment("MD5盐值");

                entity.Property(e => e.Sex)
                    .HasColumnType("int(11)")
                    .HasComment("性别 0-男 1-女");

                entity.Property(e => e.Status)
                    .HasColumnType("int(11)")
                    .HasComment("状态 0-正常");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP")
                    .HasComment("修改时间");

                entity.Property(e => e.UserAccount)
                    .HasMaxLength(200)
                    .HasComment("用户账户");

                entity.Property(e => e.UserName)
                    .HasMaxLength(200)
                    .HasComment("用户名称");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
